package tasktwo;

/**
 * @author wuwenfa
 */
public class ThreadIndexReduce extends Thread {
    public final Object lock;

    public ThreadIndexReduce(Object lock){
        this.lock = lock;
    }

    @Override
    public void run() {
        while(true){
            synchronized (lock){
                if(IndexMain.index < 100){
                    IndexMain.index--;
                    System.out.println(Thread.currentThread().getName() + "执行减1：" + IndexMain.index);
                    try {
                        Thread.sleep(60);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }else{
                    break;
                }
            }
        }
    }
}
